﻿using System;
using System.Collections.Generic;
using System.Text;
//using TMSIM.Client.CIQS.Entity.Stat.Peccancy;
//using TMSIM.Client.CIQS.Entity.Stat.BaseEntity;
using TMSIM.Client.MUS.Business;
using Microsoft.Office.Interop.Excel;

namespace TMSIM.Client.MUS.Data
{
    //public delegate string QuitExcelEventHandler();

    public class ExcelData
    {
        /// <summary>
        /// Excel应用程序对象
        /// </summary>
        static ApplicationClass myExportExcel = null;

        /// <summary>
        /// 指示是否关闭工作簿
        /// </summary>
        static bool IsClosed = false;

        //////////////////////统计违章信息//////////////

        //#region PrintStatPeccancyData
        ////public static event QuitExcelEventHandler QuitExcel;

        //public static void PrintStatPeccancyData(string filePath, System.Collections.Hashtable data, string[] keys, DateTime[] datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel == null)
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        else
        //        {
        //            myExportExcel.Quit();
        //        }

        //        _Workbook xBk;       //工作薄 
        //        _Worksheet xSt;      //工作Sheet 

        //        xBk = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);
                
        //        xSt = (_Worksheet)xBk.ActiveSheet;

        //        //myExcel.Visible = true;

        //        int row = 9;
        //        int col = 2;
        //        xSt.Cells[3, 17] = "从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 17];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < data.Count; i++)
        //        {
                    
        //            Result_Ety ety = (Result_Ety)data[keys[i]];
        //            row =9+ i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            col++;
        //            xSt.Cells[row, col] = ety.StatTypeName;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //
        //            //客车
        //            if (null == ety.CarType.Bus)
        //            {
        //                col++;
        //                xSt.Cells[row, col] = 0;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Bus.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Bus.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = 0;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Bus.Tiredness;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Bus.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Bus.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Bus.SeriousOverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            //

        //            #region 隐藏的车

        //            //
        //            //货车
        //            if (null == ety.CarType.Truck)
        //            {
        //                //col += 3;
        //                col++;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Truck.Tiredness;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Truck.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Truck.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = 0;//ety.CarType.Truck.SeriousOverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Truck.Tiredness;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Truck.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Truck.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Truck.SeriousOverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }

        //        //小车
        //            if (null == ety.CarType.Car)
        //        {
        //            //col += 3;
        //            col++;
        //            xSt.Cells[row, col] = 0;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = 0;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = 0;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = 0;//ety.CarType.Truck.SeriousOverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //        }
        //        else
        //        {
        //            col++;
        //            xSt.Cells[row, col] = ety.CarType.Car.Tiredness;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            col++;
        //            xSt.Cells[row, col] = ety.CarType.Car.OverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            col++;
        //            xSt.Cells[row, col] = ety.CarType.Car.OverLoad;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            col++;
        //            xSt.Cells[row, col] = ety.CarType.Car.SeriousOverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //        }
               
        //            #endregion

        //            //
        //            //危险品车
        //            if (null == ety.CarType.Danger)
        //            {
        //                //col += 5;
        //                //((Range)xSt.get_Range(xSt.Cells[row, col - 5], xSt.Cells[row, col])).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Danger.Tiredness;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = 0;//ety.CarType.Danger.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Danger.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = 0;//ety.CarType.Danger.SeriousOverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Danger.Overline;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Danger.Tiredness;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Danger.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Danger.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Danger.SeriousOverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = ety.CarType.Danger.Overline;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            //
        //            //合计
        //            if (row > 9 && row < data.Count + 9)
        //            {
        //                col++;
        //                rg = (Range)xSt.get_Range(xSt.Cells[row - 1, col], xSt.Cells[row, col + 1]);
        //                rg.Select();
        //                rg.Copy(Type.Missing);
        //                rg = (Range)xSt.get_Range(xSt.Cells[row, col], xSt.Cells[row, col + 1]);
        //                rg.Select();
        //                xSt.Paste(Type.Missing, Type.Missing);
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            col = 2;
        //        }
        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 27]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        ((Range)xSt.Cells[1, 1]).Select();
        //        myExportExcel.Visible = true;
        //        xSt.PrintPreview(true);
        //        //xSt.PrintOut(1, 1, 1, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
        //        xBk.Close(false, filePath, missing);
        //        myExportExcel.Quit();
        //        myExportExcel = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用FillDataToWorkBook出错", ex);
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.ActiveWorkbook.Close(false, filePath, System.Reflection.Missing.Value);
        //            myExportExcel.Quit();
        //            myExportExcel = null;
        //        }
        //    }
        //}
        //#endregion       
        
        //#region ExportStatPeccancyData
        //public static void ExportStatPeccancyData(string filePath, System.Collections.Hashtable data, string[] keys, DateTime[] datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.Quit();
        //            //myExportExcel.WorkbookBeforeClose -= new AppEvents_WorkbookBeforeCloseEventHandler(myExportExcel_WorkbookBeforeClose);
        //        }
        //        else
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        myExportExcel.WorkbookBeforeClose += new AppEvents_WorkbookBeforeCloseEventHandler(myExportExcel_WorkbookBeforeClose);
                    
        //        IsClosed = false;

        //        _Workbook xBk1;       //工作薄 
        //        _Worksheet xSt1;      //工作Sheet 

        //        xBk1 = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);
               
        //        xSt1 = (_Worksheet)xBk1.ActiveSheet;
        //        _Workbook xBk = myExportExcel.Workbooks.Add(true);
        //        _Worksheet xSt = (_Worksheet)xBk.ActiveSheet;
        //        xSt1.Activate();
        //        Range rgCopy = (Range)xSt1.get_Range(xSt1.Cells[1, 1], xSt1.Cells[9, 21]);
        //        rgCopy.Select();
        //        rgCopy.Copy(Type.Missing);
        //        xSt.Activate();
        //        xSt.Paste(Type.Missing, Type.Missing);

        //        //xBk1.Close(false, filePath, Type.Missing);
        //        //myExcel.Visible = true;

        //        int row = 0;
        //        int col = 2;
        //        xSt.Cells[3, 17] = "从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 17];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < data.Count; i++)
        //        {

        //            Result_Ety ety = (Result_Ety)data[keys[i]];
        //            row =9+ i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.StatTypeName;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //
        //            //客车
        //            if (null == ety.CarType.Bus)
        //            {
        //                //col += 4;
        //                //((Range)xSt.get_Range(xSt.Cells[row, col-4],xSt.Cells[row,col])).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Bus.Tiredness;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Bus.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = 0;// ety.CarType.Bus.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = 0;//ety.CarType.Bus.SeriousOverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = ety.CarType.Bus.Tiredness;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = ety.CarType.Bus.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = ety.CarType.Bus.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = ety.CarType.Bus.SeriousOverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            //

        //            #region 隐藏的车
                    
        //        //货车
        //        if (null == ety.CarType.Truck)
        //        {
        //            //col += 4;
        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = 0;// ety.CarType.Truck.Tiredness;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = 0;// ety.CarType.Truck.OverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = 0;//;// ety.CarType.Truck.OverLoad;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = 0;//ety.CarType.Truck.SeriousOverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //        }
        //        else
        //        {
        //            //col++;
        //            //xSt.Cells[row, col] = ety.CarType.Truck.Tiredness;
        //            //col++;
        //            //xSt.Cells[row, col] = ety.CarType.Truck.OverSpeed;
        //            //col++;
        //            //xSt.Cells[row, col] = ety.CarType.Truck.OverLoad;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.Truck.Tiredness;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.Truck.OverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.Truck.OverLoad;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.Truck.SeriousOverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //        }
        //        //
        //        //小车
        //        if (null == ety.CarType.Car)
        //        {
        //            //col += 4;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = 0;// ety.CarType.Truck.Tiredness;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = 0;// ety.CarType.Truck.OverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = 0;// ety.CarType.Truck.OverLoad;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = 0;//;//ety.CarType.Truck.SeriousOverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //        }
        //        else
        //        {
        //            //col++;
        //            //xSt.Cells[row, col] = ety.CarType.Car.Tiredness;
        //            //col++;
        //            //xSt.Cells[row, col] = ety.CarType.Car.OverSpeed;
        //            //col++;
        //            //xSt.Cells[row, col] = ety.CarType.Car.OverLoad;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.Car.Tiredness;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.Car.OverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.Car.OverLoad;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.Car.SeriousOverSpeed;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //        }
                
        //            #endregion

        //            //
        //            //危险品车
        //            if (null == ety.CarType.Danger)
        //            {
        //                //col += 5;
        //                //((Range)xSt.get_Range(xSt.Cells[row, col - 5], xSt.Cells[row, col])).Borders.Weight = XlBorderWeight.xlThin;
        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = 0;//;// ety.CarType.Danger.Tiredness;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = 0;//;//  ety.CarType.Danger.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = 0;//;// ety.CarType.Danger.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = 0;//;//  ety.CarType.Danger.SeriousOverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = 0;//;// ety.CarType.Danger.Overline;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = ety.CarType.Danger.Tiredness;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = ety.CarType.Danger.OverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = ety.CarType.Danger.OverLoad;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = ety.CarType.Danger.SeriousOverSpeed;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                xSt.Cells[row, col] = ety.CarType.Danger.Overline;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            //
        //            //合计
        //            if (row > 9 && row < data.Count+9)
        //            {
        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                rg = (Range)xSt.get_Range(xSt.Cells[row - 1, col], xSt.Cells[row, col + 1]);
        //                rg.Select();
        //                rg.Copy(Type.Missing);
        //                rg = (Range)xSt.get_Range(xSt.Cells[row, col], xSt.Cells[row, col + 1]);
        //                rg.Select();
        //                xSt.Paste(Type.Missing, Type.Missing);
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }

        //            //xSt.Cells[row, col + 1] =myExportExcel.WorksheetFunction.Sum("D" + i + ":M" + col);
        //            col = 2;
        //        }
        //        rg =(Range) xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row,20]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        //rg.Borders.Weight = XlBorderWeight.xlThin;
        //        rg.Font.Size = 10;
        //        ((Range)xSt.Cells[1, 1]).Select();
        //        //rg.set_Value(typeof(Font),((Range)xSt.Cells[7, 2]).Font);

        //        myExportExcel.Visible = true;
        //        xBk1.Close(false, filePath, Type.Missing);
                
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用FillDataToWorkBook出错", ex);
        //        QuitExcelHandler();
        //    }
        //    finally
        //    {
                
        //    }
        //}
        //#endregion

        //////////////////////统计报警信息///////////////

        //#region PrintStatAlarmData
        //public static void PrintStatAlarmData(string filePath, System.Collections.Hashtable data, string[] keys, DateTime[] datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel == null)
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        else
        //        {
        //            myExportExcel.Quit();
        //        }

        //        _Workbook xBk;       //工作薄 
        //        _Worksheet xSt;      //工作Sheet 

        //        xBk = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt = (_Worksheet)xBk.ActiveSheet;

        //        //myExcel.Visible = true;

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 7] = "时间：从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 7];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < data.Count; i++)
        //        {

        //            TMSIM.Client.CIQS.Entity.Stat.Alarm.Result_Ety ety = (TMSIM.Client.CIQS.Entity.Stat.Alarm.Result_Ety)data[keys[i]];
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            col++;
        //            xSt.Cells[row, col] = ety.StatTypeName;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //
        //            //客车
        //            //if (null == ety.CarType.BusNumber)
        //            //{
        //            //    col += 1;
        //            //}
        //            //else
        //            //{
        //            col++;
        //            xSt.Cells[row, col] = ety.CarType.BusNumber;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;                        
        //            //}
        //            ////

        //            #region 隐藏的车
                    
        //        //货车
        //        //if (null == ety.CarType.TruckNumber)
        //        //{
        //            //col++;
        //            //xSt.Cells[row, col] = 0;
        //            //((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;  
        //        //}
        //        //else
        //        //{
        //            col++;
        //            xSt.Cells[row, col] = ety.CarType.TruckNumber;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;  
        //        //}
        //        //
        //        //小车
        //        //if (null == ety.CarType.CarNumber)
        //        //{
        //            //col++;
        //            //xSt.Cells[row, col] = 0;
        //            //((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;  
        //        //}
        //        //else
        //        //{
        //            col++;
        //            xSt.Cells[row, col] = ety.CarType.CarNumber;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;  
        //        //}
                
        //            #endregion

        //            //
        //            ////危险品车
        //            //if (null == ety.CarType.DangerCarNumber)
        //            //{
        //            //    col += 1;
        //            //}
        //            //else
        //            //{
        //            col++;
        //            xSt.Cells[row, col] = ety.CarType.DangerCarNumber;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;                        
        //            //}
        //            ////
        //            //合计
        //            if (row > 8 && row < data.Count + 8)
        //            {
        //                col++;
        //                rg = (Range)xSt.get_Range(xSt.Cells[row - 1, col], xSt.Cells[row, col + 1]);
        //                rg.Select();
        //                rg.Copy(Type.Missing);
        //                rg = (Range)xSt.get_Range(xSt.Cells[row, col], xSt.Cells[row, col + 1]);
        //                rg.Select();
        //                xSt.Paste(Type.Missing, Type.Missing);
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                col++;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            col = 2;
        //        }

        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 17]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        //rg.Borders.Weight = XlBorderWeight.xlThin;
        //        ((Range)xSt.Cells[1, 1]).Select();
        //        myExportExcel.Visible = true;
        //        xSt.PrintPreview(true);
        //        //xSt.PrintOut(1, 1, 1, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
        //        xBk.Close(false, filePath, missing);
        //        myExportExcel.Quit();
        //        myExportExcel = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用FillDataToWorkBook出错", ex);
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.ActiveWorkbook.Close(false, filePath, System.Reflection.Missing.Value);
        //            myExportExcel.Quit();
        //            myExportExcel = null;
        //        }
        //    }
        //}
        //#endregion

        //#region ExportStatAlarmData
        //public static void ExportStatAlarmData(string filePath, System.Collections.Hashtable data, string[] keys, DateTime[] datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.Quit();
        //        }
        //        else
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        myExportExcel.WorkbookBeforeClose += new AppEvents_WorkbookBeforeCloseEventHandler(myExportExcel_WorkbookBeforeClose);

        //        IsClosed = false;

        //        _Workbook xBk1;       //工作薄 
        //        _Worksheet xSt1;      //工作Sheet 

        //        xBk1 = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt1 = (_Worksheet)xBk1.ActiveSheet;
        //        _Workbook xBk = myExportExcel.Workbooks.Add(true);
        //        _Worksheet xSt = (_Worksheet)xBk.ActiveSheet;
        //        xSt1.Activate();
        //        Range rgCopy = (Range)xSt1.get_Range(xSt1.Cells[1, 1], xSt1.Cells[9, 15]);
        //        rgCopy.Select();
        //        rgCopy.Copy(Type.Missing);
        //        xSt.Activate();
        //        xSt.Paste(Type.Missing, Type.Missing);

        //        int row = 0;
        //        int col = 2;
        //        xSt.Cells[3, 7] = "时间：从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 7];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < data.Count; i++)
        //        {

        //            TMSIM.Client.CIQS.Entity.Stat.Alarm.Result_Ety ety = (TMSIM.Client.CIQS.Entity.Stat.Alarm.Result_Ety)data[keys[i]];
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.StatTypeName;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //
        //            //客车
        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.BusNumber;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //货车
        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.TruckNumber;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //小车
        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.CarNumber;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //
        //            //危险品车
        //            col++;
        //            xSt.Cells[row, col] = xSt1.Cells[row, col];
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //            xSt.Cells[row, col] = ety.CarType.DangerCarNumber;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            //合计
        //            if (row > 8 && row < data.Count + 8)
        //            {
        //                col++;
        //                xSt.Cells[row, col] = xSt1.Cells[row, col];
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = ((Range)xSt1.Cells[row, col]).ColumnWidth;
        //                rg = (Range)xSt.get_Range(xSt.Cells[row - 1, col], xSt.Cells[row, col + 1]);
        //                rg.Select();
        //                rg.Copy(Type.Missing);
        //                rg = (Range)xSt.get_Range(xSt.Cells[row, col], xSt.Cells[row, col + 1]);
        //                rg.Select();
        //                xSt.Paste(Type.Missing, Type.Missing);
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                col++;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            col = 2;
        //        }
        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 17]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        rg.Font.Size = 10;
        //        //rg.Borders.Weight = XlBorderWeight.xlThin;
        //        ((Range)xSt.Cells[1, 1]).Select();

        //        myExportExcel.Visible = true;
        //        xBk1.Close(false, filePath, Type.Missing);

        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用FillDataToWorkBook出错", ex);
        //        QuitExcelHandler();
        //    }
        //    finally
        //    {

        //    }
        //}
        //#endregion

        /////////////////////统计在线时间////////////////

        //#region PrintOnlineData
        ///// <summary>
        ///// 打印统计车队在线时间报表
        ///// </summary>
        ///// <param name="etys">车队在线时间统计实体数组</param>
        //public static void PrintOnlineData(string filePath,
        //    SysCommon.Entity.Business.Stat.View.View_Statisticunit_Ety[] etys,
        //    DateTime[] datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel == null)
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        else
        //        {
        //            myExportExcel.Quit();
        //        }

        //        _Workbook xBk;       //工作薄 
        //        _Worksheet xSt;      //工作Sheet 

        //        xBk = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt = (_Worksheet)xBk.ActiveSheet;

        //        //myExcel.Visible = true;

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 5] = "时间：从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 5];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 7;
        //            //车队
        //            col++;
        //            if (etys[i].CARMEMBERNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARMEMBERNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }

        //            //在线时间
        //            col++;
        //            //if (etys[i].ONLINETIME != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].CARMEMBERNAME;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = etys[i].ONLINETIME;// 0;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            //在线里程
        //            col++;
        //            //if (etys[i].ONLINEDIST != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].ONLINEDIST;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = etys[i].ONLINEDIST;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            //在线率
        //            col++;
        //            //if (etys[i].ONLINETIME != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].ONLINERAT;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = etys[i].ONLINERAT;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            col = 2;
        //        }
        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 27]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        ((Range)xSt.Cells[1, 1]).Select();
        //        myExportExcel.Visible = true;
        //        xSt.PrintPreview(true);
        //        //xSt.PrintOut(1, 1, 1, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
        //        xBk.Close(false, filePath, missing);
        //        myExportExcel.Quit();
        //        myExportExcel = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.ActiveWorkbook.Close(false, filePath, System.Reflection.Missing.Value);
        //            myExportExcel.Quit();
        //            myExportExcel = null;
        //        }
        //    }
        //}
        //#endregion

        //#region ExportOnlineData
        ///// <summary>
        ///// 导出统计车队在线时间报表
        ///// </summary>
        ///// <param name="etys"></param>
        //public static void ExportOnlineData(string filePath,
        //    SysCommon.Entity.Business.Stat.View.View_Statisticunit_Ety[] etys,
        //    DateTime[] datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.Quit();
        //        }
        //        else
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        myExportExcel.WorkbookBeforeClose += new AppEvents_WorkbookBeforeCloseEventHandler(myExportExcel_WorkbookBeforeClose);

        //        IsClosed = false;

        //        _Workbook xBk1;       //工作薄 
        //        _Worksheet xSt1;      //工作Sheet 

        //        xBk1 = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt1 = (_Worksheet)xBk1.ActiveSheet;
        //        _Workbook xBk = myExportExcel.Workbooks.Add(true);
        //        _Worksheet xSt = (_Worksheet)xBk.ActiveSheet;
        //        xSt1.Activate();
        //        Range rgCopy = (Range)xSt1.get_Range(xSt1.Cells[1, 1], xSt1.Cells[9, 15]);
        //        rgCopy.Select();
        //        rgCopy.Copy(Type.Missing);
        //        xSt.Activate();
        //        xSt.Paste(Type.Missing, Type.Missing);

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 5] = "时间：从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 5];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 7;
        //            //车队
        //            col++;
        //            if (etys[i].CARMEMBERNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARMEMBERNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {

        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            //在线时间
        //            col++;
        //            //if (etys[i].ONLINETIME != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].ONLINETIME;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = etys[i].ONLINETIME; ;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            //在线里程
        //            col++;
        //            //if (etys[i].ONLINEDIST != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].ONLINEDIST;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = etys[i].ONLINEDIST;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            //在线率
        //            col++;
        //            //if (etys[i].ONLINETIME != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].ONLINERAT;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = etys[i].ONLINERAT; 
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            col = 2;
        //        }
        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 17]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        rg.Font.Size = 10;
        //        //rg.Borders.Weight = XlBorderWeight.xlThin;
        //        ((Range)xSt.Cells[1, 1]).Select();
        //        //((Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[1, 1])).Select();
        //        myExportExcel.Visible = true;
        //        xBk1.Close(false, filePath, Type.Missing);
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        QuitExcelHandler();
        //    }
        //}
        //#endregion

        /////////////////////查询违章信息////////////////

        //#region PrintPeccancyData

        //public static void PrintPeccancyData(string filePath,
        //    SysCommon.Entity.Business.View.View_Peccancy_Ety[] etys,
        //    DateTime[] datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel == null)
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        else
        //        {
        //            myExportExcel.Quit();
        //        }

        //        _Workbook xBk;       //工作薄 
        //        _Worksheet xSt;      //工作Sheet 

        //        xBk = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt = (_Worksheet)xBk.ActiveSheet;

        //        //myExcel.Visible = true;

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 11] = "时间：从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 11];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 4.5;
        //            //违章类型
        //            col++;
        //            if (etys[i].INFONAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].INFONAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            }
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //车牌号
        //            col++;
        //            if (etys[i].CARPLATE != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARPLATE;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //开始时间
        //            col++;
        //            if (etys[i].BEGINTIME != null)
        //            {
        //                string begintime=etys[i].BEGINTIME.ToString();
        //                ((Range)xSt.Cells[row, col]).set_Value(XlRangeValueDataType.xlRangeValueDefault, begintime);
        //                //xSt.Cells[row, col] = begintime;// etys[i].BEGINTIME.ToString();
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            //else
        //            //{
        //            //    xSt.Cells[row, col] = "";
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 16.50;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //结束时间
        //            col++;
        //            if (etys[i].ENDTIME != null)
        //            {
        //                string endtime=etys[i].ENDTIME.ToString();
        //                ((Range)xSt.Cells[row, col]).set_Value(XlRangeValueDataType.xlRangeValueDefault, endtime);// etys[i].ENDTIME.ToString();
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            //else
        //            //{
        //            //    xSt.Cells[row, col] = "";
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 16.50;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //持续时间
        //            col++;
        //            //if (etys[i].OVERTIME != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].OVERTIME;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = etys[i].OVERTIME;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //是否已发送
        //            col++;
        //            if (etys[i].SENDED != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].SENDED;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //道路名称
        //            col++;
        //            if (etys[i].ROADNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].ROADNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //区域
        //            col++;
        //            if (etys[i].CITYNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CITYNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //处理结果
        //            col++;
        //            if (etys[i].RESULT != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].RESULT;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //司机名称
        //            col++;
        //            if (etys[i].DRIVERNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].DRIVERNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //车辆类型
        //            col++;
        //            if (etys[i].CARTYPENAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARTYPENAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            col = 2;
        //        }
        //        myExportExcel.Visible = true;
        //        xSt.PrintPreview(true);
        //        //xSt.PrintOut(1, 1, 1, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
        //        xBk.Close(false, filePath, missing);
        //        myExportExcel.Quit();
        //        myExportExcel = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.ActiveWorkbook.Close(false, filePath, System.Reflection.Missing.Value);
        //            myExportExcel.Quit();
        //            myExportExcel = null;
        //        }
        //    }
        //}
        //#endregion

        //#region ExportPeccancyData
        //public static void ExportPeccancyData(
        //    string filePath,
        //    SysCommon.Entity.TMSIM.WS.Query.View_Peccancy_Ety[] etys,
        //    DateTime[] datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.Quit();
        //        }
        //        else
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        myExportExcel.WorkbookBeforeClose += new AppEvents_WorkbookBeforeCloseEventHandler(myExportExcel_WorkbookBeforeClose);

        //        IsClosed = false;

        //        _Workbook xBk1;       //工作薄 
        //        _Worksheet xSt1;      //工作Sheet 

        //        xBk1 = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt1 = (_Worksheet)xBk1.ActiveSheet;
        //        _Workbook xBk = myExportExcel.Workbooks.Add(true);
        //        _Worksheet xSt = (_Worksheet)xBk.ActiveSheet;
        //        xSt1.Activate();
        //        Range rgCopy = (Range)xSt1.get_Range(xSt1.Cells[1, 1], xSt1.Cells[9, 15]);
        //        rgCopy.Select();
        //        rgCopy.Copy(Type.Missing);
        //        xSt.Activate();
        //        xSt.Paste(Type.Missing, Type.Missing);

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 5] = "时间：从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 5];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 4.5;
        //            //违章类型
        //            col++;
        //            if (etys[i].INFONAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].INFONAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            }

        //            //车牌号
        //            col++;
        //            if (etys[i].CARPLATE != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARPLATE;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            //开始时间
        //            col++;
        //            if (etys[i].BEGINTIME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].BEGINTIME.ToString();
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            //else
        //            //{
        //            //    xSt.Cells[row, col] = "";
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 16.5;

        //            //结束时间
        //            col++;
        //            if (etys[i].ENDTIME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].ENDTIME.ToString();
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            //else
        //            //{
        //            //    xSt.Cells[row, col] = "";
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 16.5;

        //            //持续时间
        //            col++;
        //            //if (etys[i].OVERTIME != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].OVERTIME;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = "";
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //是否已发送
        //            col++;
        //            if (etys[i].SENDED != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].SENDED;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //道路名称
        //            col++;
        //            if (etys[i].ROADNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].ROADNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            //区域
        //            col++;
        //            if (etys[i].CITYNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CITYNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //处理结果
        //            col++;
        //            if (etys[i].RESULT != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].RESULT;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //司机名称
        //            col++;
        //            if (etys[i].DRIVERNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].DRIVERNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //车辆类型
        //            col++;
        //            if (etys[i].CARTYPENAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARTYPENAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            col = 2;
        //        }
        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 17]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        rg.Font.Size = 10;
        //        ((Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[1, 1])).Select();
        //        myExportExcel.Visible = true;
        //        xBk1.Close(false, filePath, Type.Missing);
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        QuitExcelHandler();
        //    }
        //}
        //#endregion

        ///////////////////查询日志信息/////////////////
        #region PrintLogData
        public static void PrintLogData(string filePath, SysCommon.Entity.View_Userlogs_Ety[] etys, DateTime[] datetime)
        {
            try
            {
                object missing = System.Reflection.Missing.Value;
                if (myExportExcel == null)
                {
                    myExportExcel = new ApplicationClass();
                }
                else
                {
                    myExportExcel.Quit();
                }

                _Workbook xBk;       //工作薄 
                _Worksheet xSt;      //工作Sheet 

                xBk = myExportExcel.Workbooks.Open(filePath, missing, false,
                    missing, missing, missing, missing, missing,
                    missing, missing, missing, missing, missing, missing, missing);

                xSt = (_Worksheet)xBk.ActiveSheet;

                //myExcel.Visible = true;

                int row = 8;
                int col = 2;
                xSt.Cells[3, 6] = "时间：从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
                Range rg = (Range)xSt.Cells[3, 11];
                //设置对齐方式            
                rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
                rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

                for (int i = 0; i < etys.Length; i++)
                {
                    //序号
                    row = 8 + i;
                    int index = i + 1;
                    xSt.Cells[row, col] = index;
                    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
                    ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
                    ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    ((Range)xSt.Cells[row, col]).ColumnWidth = 4.5;
                    //日志内容
                    col++;
                    if (etys[i].CONTENT != null)
                    {
                        xSt.Cells[row, col] = etys[i].CONTENT;
                        ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
                        ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
                        ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
                        ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
                    }
                    else
                    {
                        ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
                    }

                    //日期时间
                    col++;
                    if (etys[i].GENERATETIME != null)
                    {
                        xSt.Cells[row, col] = etys[i].GENERATETIME.ToString();
                        ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
                        ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
                        ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;

                    }
                    //else
                    //{
                    //    xSt.Cells[row, col] = "";
                    //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
                    //    ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
                    //    ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    //}
                    ((Range)xSt.Cells[row, col]).ColumnWidth = 16.5;

                    //客户端IP
                    col++;
                    if (etys[i].COMPUTERIP != null)
                    {
                        xSt.Cells[row, col] = etys[i].COMPUTERIP;
                        ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
                        ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
                        ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    }
                    else
                    {
                        xSt.Cells[row, col] = "";
                        ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
                        ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
                        ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    }
                    ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

                    //操作员
                    col++;
                    if (etys[i].USERNAME != null)
                    {
                        xSt.Cells[row, col] = etys[i].USERNAME;
                        ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
                    }
                    else
                    {
                        xSt.Cells[row, col] = "";
                        ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
                    }
                    ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
                    ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

                    col = 2;
                }
                myExportExcel.Visible = true;
                xSt.PrintPreview(true);
                //xSt.PrintOut(1, 1, 1, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                xBk.Close(false, filePath, missing);
                myExportExcel.Quit();
                myExportExcel = null;
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用PrintLogData出错", ex);
                if (myExportExcel != null)
                {
                    myExportExcel.ActiveWorkbook.Close(false, filePath, System.Reflection.Missing.Value);
                    myExportExcel.Quit();
                    myExportExcel = null;
                }
            }
        }

        #endregion


        /////////////////////查询报警信息////////////////

        //#region PrintAlarmData
        //public static void PrintAlarmData(string filePath,
        //    SysCommon.Entity.Business.View.View_AlarmHistory_Ety[] etys,
        //    DateTime[] datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel == null)
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        else
        //        {
        //            myExportExcel.Quit();
        //        }

        //        _Workbook xBk;       //工作薄 
        //        _Worksheet xSt;      //工作Sheet 

        //        xBk = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt = (_Worksheet)xBk.ActiveSheet;

        //        //myExcel.Visible = true;

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 11] = "时间：从 " + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 11];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 4.5;
        //            //报警内容
        //            col++;
        //            if (etys[i].INFO != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].INFO;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //                ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            }

        //            //发生时间
        //            col++;
        //            if (etys[i].HAPPENTIME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].HAPPENTIME.ToString() ;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //                ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //            }
        //            //else
        //            //{
        //            //    xSt.Cells[row, col] = "";
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //    ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            //    ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 16.5;

        //            //车牌号
        //            col++;
        //            if (etys[i].CARPLATE != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARPLATE;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //                ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //                ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            //经度
        //            col++;
        //            //if (etys[i].LONGITUDE != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].LONGITUDE;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] =etys[i].LONGITUDE;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            //纬度
        //            col++;
        //            //if (etys[i].LATITUDE != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].LATITUDE;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = etys[i].LATITUDE;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            //区域
        //            col++;
        //            if (etys[i].CITYNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CITYNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //道路名称
        //            col++;
        //            if (etys[i].ROADNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].ROADNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            //速度
        //            col++;
        //            //if (etys[i].SPEED != null)
        //            //{
        //            //    xSt.Cells[row, col] = etys[i].SPEED;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            xSt.Cells[row, col] = etys[i].SPEED;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //司机名称
        //            col++;
        //            if (etys[i].DRIVERNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].DRIVERNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //车辆类型
        //            col++;
        //            if (etys[i].CARTYPENAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARTYPENAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment = XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            col = 2;
        //        }
        //        myExportExcel.Visible = true;
        //        xSt.PrintPreview(true);
        //        //xSt.PrintOut(1, 1, 1, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
        //        xBk.Close(false, filePath, missing);
        //        myExportExcel.Quit();
        //        myExportExcel = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.ActiveWorkbook.Close(false, filePath, System.Reflection.Missing.Value);
        //            myExportExcel.Quit();
        //            myExportExcel = null;
        //        }
        //    }
        //}
        //#endregion

        //////////////////查询当前监控车辆信息///////////

        //#region PrintCurrentStakeoutData
        //public static void PrintCurrentStakeoutData(string filePath,
        //    SysCommon.Entity.TMSIM.WS.Stakeout.LatestGPS_Ety[] etys)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel == null)
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        else
        //        {
        //            myExportExcel.Quit();
        //        }

        //        _Workbook xBk;       //工作薄 
        //        _Worksheet xSt;      //工作Sheet 

        //        xBk = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt = (_Worksheet)xBk.ActiveSheet;

        //        //myExcel.Visible = true;

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 11] = "时间： " + System.DateTime.Now.ToString();// + datetime[0].ToShortDateString() + " 到 " + datetime[1].ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 11];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 4.5;

        //            //车牌号码
        //            col++;
        //            if (etys[i].CARPLATE != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARPLATE;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 10;
        //            }

        //            //信号时间
        //            col++;
        //            if (etys[i].DATEDMYTIME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].DATEDMYTIME.ToString();
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;

        //            }
        //            //else
        //            //{
        //            //    xSt.Cells[row, col] = "";
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 16.5;

        //            //道路限速
        //            col++;
        //            //if (etys[i].LIMITEDSPEED != null)
        //            //{
        //            xSt.Cells[row, col] = etys[i].LIMITEDSPEED;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            //xSt.Cells[row, col] = "";
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).VerticalAlignment=XlVAlign.xlVAlignCenter;
        //            ((Range)xSt.Cells[row, col]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth =8;

        //            //城市
        //            col++;
        //            if (etys[i].POSITIONCITY != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].POSITIONCITY;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //道路
        //            col++;
        //            if (etys[i].POSITIONROAD != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].POSITIONROAD;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            //所在车队
        //            col++;
        //            if (etys[i].CARMEMBERNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARMEMBERNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            //驾驶员
        //            col++;
        //            //if (etys[i].DRIVERID != null)
        //            //{
        //            xSt.Cells[row, col] = etys[i].DRIVERID;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            //xSt.Cells[row, col] = "";
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //速度
        //            col++;
        //            //if (etys[i].SPEED != null)
        //            //{
        //            xSt.Cells[row, col] = etys[i].SPEED;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            //xSt.Cells[row, col] = "";
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 8;

        //            //经度
        //            col++;
        //            //if (etys[i].LONGITUDE != null)
        //            //{
        //            xSt.Cells[row, col] = etys[i].LONGITUDE;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            //xSt.Cells[row, col] = "";
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            //纬度
        //            col++;
        //            //if (etys[i].LATITUDE != null)
        //            //{
        //            xSt.Cells[row, col] = etys[i].LATITUDE;
        //            //    ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            //else
        //            //{
        //            //xSt.Cells[row, col] = "";
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            //}
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 10;

        //            col = 2;
        //        }

        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 17]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        rg.Font.Size = 10;

        //        myExportExcel.Visible = true;
        //        myExportExcel.UserControl = true;
        //        xSt.PageSetup.PrintArea = "$A$1:$L$"+row;
        //        xSt.PrintPreview(true);
        //        //xSt.PrintOut(1, 1, 1, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
        //        xBk.Close(false, filePath, missing);
        //        myExportExcel.Quit();
        //        myExportExcel = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.ActiveWorkbook.Close(false, filePath, System.Reflection.Missing.Value);
        //            myExportExcel.Quit();
        //            myExportExcel = null;
        //        }
        //    }
        //}
        //#endregion

        //////////////////统计车辆信息///////////////////

        //#region PrintVehicleInfoByCarmember
        ///// <summary>
        ///// 按车队统计车辆信息
        ///// </summary>
        ///// <param name="filePath">模板文件路径</param>
        ///// <param name="etys">统计实体</param>
        ///// <param name="datetime">统计时间</param>
        //public static void PrintVehicleInfoByCarmember(string filePath,
        //    SysCommon.Entity.Business.Stat.View.View_statcarbycarmember_Ety[] etys,
        //    DateTime datetime)
        //{

        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel == null)
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        else
        //        {
        //            myExportExcel.Quit();
        //        }

        //        _Workbook xBk;       //工作薄 
        //        _Worksheet xSt;      //工作Sheet 

        //        xBk = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt = (_Worksheet)xBk.ActiveSheet;

        //        //myExcel.Visible = true;

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 5] = "时间： " + datetime.ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 5];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 7;
        //            //车队
        //            col++;
        //            if (etys[i].CARMEMBERNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARMEMBERNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }

        //            //车辆类型
        //            col++;
        //            if (etys[i].CARTYPENAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARTYPENAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            //车辆用途
        //            col++;
        //            if (etys[i].CARUSENESS != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARUSENESS;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            //车辆数量
        //            col++;
        //            xSt.Cells[row, col] = etys[i].CARNUMBER;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;

        //            col = 2;
        //        }
        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 7]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        ((Range)xSt.Cells[1, 1]).Select();
        //        myExportExcel.Visible = true;
        //        xSt.PrintPreview(true);

        //        xBk.Close(false, filePath, missing);
        //        myExportExcel.Quit();
        //        myExportExcel = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.ActiveWorkbook.Close(false, filePath, System.Reflection.Missing.Value);
        //            myExportExcel.Quit();
        //            myExportExcel = null;
        //        }
        //    }
        //}
        //#endregion

        //#region PrintVehicleInfoByArea
        ///// <summary>
        ///// 按辖区统计车辆信息
        ///// </summary>
        ///// <param name="filePath">模板文件路径</param>
        ///// <param name="etys">统计实体</param>
        ///// <param name="datetime">统计时间</param>
        //public static void PrintVehicleInfoByArea(string filePath,
        //    SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys,
        //    DateTime datetime)
        //{

        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel == null)
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        else
        //        {
        //            myExportExcel.Quit();
        //        }

        //        _Workbook xBk;       //工作薄 
        //        _Worksheet xSt;      //工作Sheet 

        //        xBk = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt = (_Worksheet)xBk.ActiveSheet;

        //        //myExcel.Visible = true;

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 5] = "时间： " + datetime.ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 5];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 7;
        //            //辖区
        //            col++;
        //            if (etys[i].AREANAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].AREANAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }

        //            //车辆类型
        //            col++;
        //            if (etys[i].CARTYPENAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARTYPENAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            //车辆用途
        //            col++;
        //            if (etys[i].CARUSENESS != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARUSENESS;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            //车辆数量
        //            col++;
        //            xSt.Cells[row, col] = etys[i].CARNUMBER;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;

        //            col = 2;
        //        }
        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 7]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        ((Range)xSt.Cells[1, 1]).Select();
        //        myExportExcel.Visible = true;
        //        xSt.PrintPreview(true);

        //        xBk.Close(false, filePath, missing);
        //        myExportExcel.Quit();
        //        myExportExcel = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.ActiveWorkbook.Close(false, filePath, System.Reflection.Missing.Value);
        //            myExportExcel.Quit();
        //            myExportExcel = null;
        //        }
        //    }
        //}
        //#endregion

        //#region ExportVehicleInfoByCarmember
        //public static void ExportVehicleInfoByCarmember(
        //    string filePath,
        //    SysCommon.Entity.Business.Stat.View.View_statcarbycarmember_Ety[] etys,
        //    DateTime datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.Quit();
        //        }
        //        else
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        myExportExcel.WorkbookBeforeClose += new AppEvents_WorkbookBeforeCloseEventHandler(myExportExcel_WorkbookBeforeClose);

        //        IsClosed = false;

        //        _Workbook xBk1;       //工作薄 
        //        _Worksheet xSt1;      //工作Sheet 

        //        xBk1 = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt1 = (_Worksheet)xBk1.ActiveSheet;
        //        _Workbook xBk = myExportExcel.Workbooks.Add(true);
        //        _Worksheet xSt = (_Worksheet)xBk.ActiveSheet;
        //        xSt1.Activate();
        //        Range rgCopy = (Range)xSt1.get_Range(xSt1.Cells[1, 1], xSt1.Cells[9, 7]);
        //        rgCopy.Select();
        //        rgCopy.Copy(Type.Missing);
        //        xSt.Activate();
        //        xSt.Paste(Type.Missing, Type.Missing);

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 5] = "时间： " + datetime.ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 5];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 7;
        //            //车队
        //            col++;
        //            if (etys[i].CARMEMBERNAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARMEMBERNAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }

        //            //车辆类型
        //            col++;
        //            if (etys[i].CARTYPENAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARTYPENAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;

        //            //车辆用途
        //            col++;
        //            if (etys[i].CARUSENESS != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARUSENESS;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;

        //            //车辆数量
        //            col++;

        //                xSt.Cells[row, col] = etys[i].CARNUMBER.ToString();
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;

        //            col = 2;
        //        }
        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 7]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        rg.Font.Size = 10;
        //        ((Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[1, 1])).Select();
        //        myExportExcel.Visible = true;
        //        xBk1.Close(false, filePath, Type.Missing);
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        QuitExcelHandler();
        //    }
        //}
        //#endregion

        //#region ExportVehicleInfoByArea
        //public static void ExportVehicleInfoByArea(
        //    string filePath,
        //    SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys,
        //    DateTime datetime)
        //{
        //    try
        //    {
        //        object missing = System.Reflection.Missing.Value;
        //        if (myExportExcel != null)
        //        {
        //            myExportExcel.Quit();
        //        }
        //        else
        //        {
        //            myExportExcel = new ApplicationClass();
        //        }
        //        myExportExcel.WorkbookBeforeClose += new AppEvents_WorkbookBeforeCloseEventHandler(myExportExcel_WorkbookBeforeClose);

        //        IsClosed = false;

        //        _Workbook xBk1;       //工作薄 
        //        _Worksheet xSt1;      //工作Sheet 

        //        xBk1 = myExportExcel.Workbooks.Open(filePath, missing, false,
        //            missing, missing, missing, missing, missing,
        //            missing, missing, missing, missing, missing, missing, missing);

        //        xSt1 = (_Worksheet)xBk1.ActiveSheet;
        //        _Workbook xBk = myExportExcel.Workbooks.Add(true);
        //        _Worksheet xSt = (_Worksheet)xBk.ActiveSheet;
        //        xSt1.Activate();
        //        Range rgCopy = (Range)xSt1.get_Range(xSt1.Cells[1, 1], xSt1.Cells[9, 7]);
        //        rgCopy.Select();
        //        rgCopy.Copy(Type.Missing);
        //        xSt.Activate();
        //        xSt.Paste(Type.Missing, Type.Missing);

        //        int row = 8;
        //        int col = 2;
        //        xSt.Cells[3, 5] = "时间： " + datetime.ToShortDateString();
        //        Range rg = (Range)xSt.Cells[3, 5];
        //        //设置对齐方式            
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //        for (int i = 0; i < etys.Length; i++)
        //        {
        //            //序号
        //            row = 8 + i;
        //            int index = i + 1;
        //            xSt.Cells[row, col] = index;
        //            ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 7;
        //            //车队
        //            col++;
        //            if (etys[i].AREANAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].AREANAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }
        //            else
        //            {
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //                ((Range)xSt.Cells[row, col]).ColumnWidth = 20;
        //            }

        //            //车辆类型
        //            col++;
        //            if (etys[i].CARTYPENAME != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARTYPENAME;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;

        //            //车辆用途
        //            col++;
        //            if (etys[i].CARUSENESS != null)
        //            {
        //                xSt.Cells[row, col] = etys[i].CARUSENESS;
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            else
        //            {
        //                xSt.Cells[row, col] = "";
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            }
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;

        //            //车辆数量
        //            col++;

        //                xSt.Cells[row, col] = etys[i].CARNUMBER.ToString();
        //                ((Range)xSt.Cells[row, col]).Borders.Weight = XlBorderWeight.xlThin;
        //            ((Range)xSt.Cells[row, col]).ColumnWidth = 20;

        //            col = 2;
        //        }
        //        rg = (Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[row, 7]);
        //        rg.VerticalAlignment = XlVAlign.xlVAlignCenter;
        //        rg.HorizontalAlignment = XlHAlign.xlHAlignCenter;
        //        rg.Font.Size = 10;
        //        ((Range)xSt.get_Range(xSt.Cells[1, 1], xSt.Cells[1, 1])).Select();
        //        myExportExcel.Visible = true;
        //        xBk1.Close(false, filePath, Type.Missing);
        //    }
        //    catch (Exception ex)
        //    {
        //        SysCommon.Global.mainLog.Error("调用PrintOnlineData出错", ex);
        //        QuitExcelHandler();
        //    }
        //}
        //#endregion

        ///////////////////Excel事件处理///////////////

        #region QuitExcelHandler()
        public static void QuitExcelHandler()
        {
            try
            {
                myExportExcel.Quit();
                myExportExcel = null;
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用QuitExcel()方法错误",ex);
            }
        }
        #endregion

        #region myExportExcel_WorkbookBeforeClose
        static void myExportExcel_WorkbookBeforeClose(Workbook Wb, ref bool Cancel)
        {
            if (IsClosed) return;

            if (myExportExcel.Workbooks.Count > 1 && Wb.Name != "Sheet1")
            {
                Wb.Close(false, Type.Missing, Type.Missing);
            }
            else
            {
                if (myExportExcel.Workbooks.Count == 1)
                {
                    IsClosed = true;
                }
            }
        }
        #endregion
        
    }
}
